using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;

namespace DataAccess
{
    public enum p_COMPANY_FIELD
    {
        OU_CODE,
		COMPANY_CODE,
		COMPANY_NAME_EN,
		COMPANY_NAME_TH,
		ADDR1,
		ADDR2,
		ADDR3,
		CITY,
		PSTSD,
		TELNO,
		FAXNO,
		LOGO,
		AUTH_LDAP,
		AUTH_USERNAME,
		AUTH_PASSWORD,
		USE_FLAG,
		ACTIVE_FLAG,
		COMPANY_NAME_ABBR
    }

    public class p_COMPANY : AbstractProperty
    {
        private OPERATOR CONDITION = OPERATOR.AND; //AND = Default
        private string string_criteria = "";
        private List<Hashtable> hashtable_criteria = new List<Hashtable>();
        private int cal_criteria = 0;

        public string OU_CODE { get; set; }
		public string COMPANY_CODE { get; set; }
		public string COMPANY_NAME_EN { get; set; }
		public string COMPANY_NAME_TH { get; set; }
		public string ADDR1 { get; set; }
		public string ADDR2 { get; set; }
		public string ADDR3 { get; set; }
		public string CITY { get; set; }
		public string PSTSD { get; set; }
		public string TELNO { get; set; }
		public string FAXNO { get; set; }
		public byte[] LOGO { get; set; }
		public string AUTH_LDAP { get; set; }
		public string AUTH_USERNAME { get; set; }
		public string AUTH_PASSWORD { get; set; }
		public string USE_FLAG { get; set; }
		public string ACTIVE_FLAG { get; set; }
		public string COMPANY_NAME_ABBR { get; set; }

        public override string getStringCriteria()
        {
            return string_criteria.ToLower().Replace("where", "");
        }

        public override List<Hashtable> getHashtableCriteria()
        {
            return hashtable_criteria;
        }

        public override void setCriteria(string cmd)
        {
            this.string_criteria = cmd;
        }

        public override void setCriteria(Enum column_name, CRITERIA_FLAG cf, object Value)
        {
            cal_criteria++;
            Hashtable h = new Hashtable();
            h.Add(column_name.ToString() + cf.GetDescription().Replace("{val}", ":cri_" + cal_criteria.ToString() + column_name.ToString()), ":cri_" + cal_criteria.ToString() + column_name.ToString() + "๐" + Value);
            this.hashtable_criteria.Add(h);
        }

        public override void clearCriteria()
        {
            cal_criteria = 0;
            this.string_criteria = "";
            this.hashtable_criteria.Clear();
        }

        public override string getOperator()
        {
            return this.CONDITION.ToString();
        }

        public override void setOperator(OPERATOR obj)
        {
            this.CONDITION = obj;
        }
    }
}
